package com.jwthhealth_pub.old.physicalfitness.view.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.old.common.Address.Address;
import com.jwthhealth_pub.old.physicalfitness.view.IndividualChoiceCityActivity;

import java.util.List;

/**
 * Created by Administrator on 2017/1/16.
 */
public class ChoiceCityAdatper extends RecyclerView.Adapter {


    private IndividualChoiceCityActivity activity;
    private List<Address> list;

    public ChoiceCityAdatper(IndividualChoiceCityActivity individualChoiceCityActivity, List<Address> list) {
        this.activity = individualChoiceCityActivity;
        this.list = list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(activity, R.layout.item_choice_city, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        Address address = list.get(position);
        viewHolder.item.setText(address.getName());

        viewHolder.clickLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                

            }
        });

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{

        TextView item;
        RelativeLayout clickLayout;

        public ViewHolder(View itemView) {
            super(itemView);
            item = (TextView) itemView.findViewById(R.id.title);
            clickLayout = (RelativeLayout) itemView.findViewById(R.id.click_layout);
        }
    }
}
